package com.ruoyi.web.controller.laiqianba.account;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.AccountProductInfoHis;
import com.ruoyi.account.service.IAccountProductInfoHisService;
import com.ruoyi.web.wrapper.AccountProductInfoHisWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品账户流水Controller
 * 
 * @author ruoyi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/account/productInfoHis")
public class AccountProductInfoHisController extends BaseController
{
    @Autowired
    private IAccountProductInfoHisService accountProductInfoHisService;

    /**
     * 查询产品账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:productInfoHis:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountProductInfoHis accountProductInfoHis)
    {
        startPage();
        List<Map<String, Object>> list = accountProductInfoHisService.selectAccountProductInfoHisMapList(accountProductInfoHis);
        list = new AccountProductInfoHisWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出产品账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:productInfoHis:export')")
    @Log(title = "产品账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountProductInfoHis accountProductInfoHis)
    {
        List<AccountProductInfoHis> list = accountProductInfoHisService.selectAccountProductInfoHisList(accountProductInfoHis);
        ExcelUtil<AccountProductInfoHis> util = new ExcelUtil<AccountProductInfoHis>(AccountProductInfoHis.class);
        util.exportExcel(response, list, "产品账户流水数据");
    }

    /**
     * 获取产品账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:productInfoHis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountProductInfoHisService.selectAccountProductInfoHisById(id));
    }

    /**
     * 新增产品账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:productInfoHis:add')")
    @Log(title = "产品账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountProductInfoHis accountProductInfoHis)
    {
        return toAjax(accountProductInfoHisService.insertAccountProductInfoHis(accountProductInfoHis));
    }

    /**
     * 修改产品账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:productInfoHis:edit')")
    @Log(title = "产品账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountProductInfoHis accountProductInfoHis)
    {
        return toAjax(accountProductInfoHisService.updateAccountProductInfoHis(accountProductInfoHis));
    }

    /**
     * 删除产品账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:productInfoHis:remove')")
    @Log(title = "产品账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountProductInfoHisService.deleteAccountProductInfoHisByIds(ids));
    }
}
